import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'

import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN' // element-ui lang

import enLocale from './frame/en'
import zhLocale from './frame/zh'

import enSys from './frame/modules/sys_en.js'
import zhSys from './frame/modules/sys_zh.js'

import enData from './frame/modules/data_en.js'
import zhData from './frame/modules/data_zh.js'

import enCustomer from './frame/modules/customer_en.js'
import zhCustomer from './frame/modules/customer_zh.js'

import zhStrategy from './frame/modules/strategy_zh.js'
import enStrategy from './frame/modules/strategy_en.js'

// 项目
import enProj from './proj/en'
import zhProj from './proj/zh'

// 现货业务
import spotZh from './frame/modules/spot_zh'
import spotEn from './frame/modules/spot_en'

// 仓储管理
import enStore from './frame/modules/store_en.js'
import zhStore from './frame/modules/store_zh.js'

// 财务管理
import enFinance from './frame/modules/finance_en.js'
import zhFinance from './frame/modules/finance_zh.js'

// 机构管理
import enFunction from './frame/modules/function_en.js'
import zhFunction from './frame/modules/function_zh.js'

// 业务流程
import enFunctionBpm from './frame/modules/functionBpm_en.js'
import zhFunctionBpm from './frame/modules/functionBpm_zh.js'

// 衍生品业务
import enDerivative from './frame/modules/derivative_en.js'
import zhDerivative from './frame/modules/derivative_zh.js'

// 行情数据
import enQuotation from './frame/modules/quotation_en.js'
import zhQuotation from './frame/modules/quotation_zh.js'

// 参照窗体
import enDialog from './frame/modules/dialog_en'
import zhDialog from './frame/modules/dialog_zh'

// 系统管理
import enSystemManager from './frame/modules/systemManager_en'
import zhSystemManager from './frame/modules/systemManager_zh'

// 个人办公
import enPsManage from './frame/modules/ps_en'
import zhPsManage from './frame/modules/ps_zh'

Vue.use(VueI18n)

const messages = {
  en: {
    ...enLocale,
    ...elementEnLocale,
    ...enProj,
    ...enSys,
    ...enData,
    ...enCustomer,
    ...enStrategy,
    ...spotEn,
    ...enStore,
    ...enFinance,
    ...enFunction,
    ...enFunctionBpm,
    ...enDerivative,
    ...enQuotation,
    ...enDialog,
    ...enSystemManager,
    ...enPsManage
  },
  zh: {
    ...zhLocale,
    ...elementZhLocale,
    ...zhProj,
    ...zhSys,
    ...zhData,
    ...zhCustomer,
    ...zhStrategy,
    ...spotZh,
    ...zhStore,
    ...zhFinance,
    ...zhFunction,
    ...zhFunctionBpm,
    ...zhDerivative,
    ...zhQuotation,
    ...zhDialog,
    ...zhSystemManager,
    ...zhPsManage
  }
}

const i18n = new VueI18n({
  locale: Cookies.get('language') || 'zh', // set locale
  messages // set locale messages
})

window.i18n = i18n
export default i18n
